#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
using namespace std;


class Solution {
public:
	int titleToNumber(string s) {
		int ans = 0;
		int power = 1;
		for (int i = 0; i < s.length(); ++i){
			ans += (s[s.length() - i - 1] - 'A' + 1) * power;
			power *= 26;
		}
		return ans;
	}
};

int main(int argc, char** argv){
	cout << Solution().titleToNumber("AB") << endl;
	return 0;
}